﻿using Xejen.Hosting;
using Xejen.Logger;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace Xejen.Framework.Web.Test
{
    public class WebHostConfiguration
    {
        public string SqlConnectionString { get; set; }
        // 其他 Web 主机配置属性...
    }

    public class MyDbContext : DbContext { }

    public class WebAppHostBase : AppHostBase
    {
        public WebAppHostBase(ILoggerManager loggerManager) : base(loggerManager)
        {
        }

        public WebAppHostBase(string[] args, ILoggerManager loggerManager) : base(args, loggerManager)
        {
        }

        public WebAppHostBase(HostConfiguration configuration, ILoggerManager loggerManager) : base(configuration, loggerManager)
        {
        }

        protected override void ConfigureServices(IServiceCollection services)
        {
            base.ConfigureServices(services);

            //// 添加 MVC 服务
            //services.AddControllersWithViews();

            //// 添加身份验证、授权等其他服务

            //// 添加数据库服务，使用 SQL Server
            //services.AddDbContext<MyDbContext>(options =>
            //{
            //    options.UseSqlServer(Configuration.GetConnectionString("SqlConnection"));
            //});
        }

        //public virtual void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        //{
        //    // 配置 HTTP 请求处理管道
        //    if (env.IsDevelopment())
        //    {
        //        app.UseDeveloperExceptionPage();
        //    }
        //    else
        //    {
        //        app.UseExceptionHandler("/Home/Error");
        //        app.UseHsts();
        //    }

        //    app.UseHttpsRedirection();
        //    app.UseStaticFiles();

        //    app.UseRouting();

        //    app.UseAuthorization();

        //    app.UseEndpoints(endpoints =>
        //    {
        //        endpoints.MapControllerRoute(
        //            name: "default",
        //            pattern: "{controller=Home}/{action=Index}/{id?}");
        //    });
        //}
    }

}
